//
//  BLETransfer.h
//  BLESDKDemo
//
//  Created by 李阳 on 2018/4/6.
//  Copyright © 2018年 李阳. All rights reserved.
//

#import <CoreGraphics/CoreGraphics.h>
#import "BLEConstant.h"

/// 命令类别
typedef NS_ENUM(NSUInteger, BLERequestType)
{
    BLERequestNormal, ///< 普通命令
    BLERequestMedia, ///< 媒体命令
    BLERequestContact ///< 联系人命令
};

/// 写入方式
typedef NS_ENUM(NSUInteger, BLEWriteWay)
{
    BLEWriteToWriteCharacteristic, ///< 写入写特征
    BLEWriteToNotifyCharacteristic ///< 写入通知特征
};


/// 蓝牙数据传输
@interface BLERequest : NSObject

/// 请求名称
@property (nonatomic, copy) NSString *cmdName;

/// 超时时间 默认10s
@property (nonatomic, assign) CGFloat timeout;

/// 请求类型
@property (nonatomic, assign) BLERequestType type;

#pragma mark Write
/// 发送的数据
@property (nonatomic, strong) NSData *sentData;
/// 写入的通道
@property (nonatomic, assign) BLEWritableChannel writeChannel;
/// 写入的方式
@property (nonatomic, assign) BLEWriteWay writeWay;


#pragma mark Response

/// 响应数据的长度
@property (nonatomic, assign, readonly) NSInteger responseDataLength;
/// 应该相应的次数
@property (nonatomic, assign) NSInteger shouldResponseTimes;
/// 实际响应的次数
@property (nonatomic, assign, readonly) NSInteger responseTimes;
/// 响应的数据
@property (nonatomic, strong, readonly) NSData *responseData;
/// 响应的数据数组 已做好截取
@property (nonatomic, strong, readonly) NSArray<NSData *> *responseDatas;


- (instancetype)initWithSentData:(NSData *)data;
- (instancetype)initWithSentData:(NSData *)data
                            type:(BLERequestType)type;

#pragma mark NSObject

- (BOOL)isEqualToRequest:(BLERequest *)request;

@end
